<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>axios练习</title>
  </head>
  <body>
    <div id="box"></div>
    <button id="btn">发送请求</button>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.8.4/axios.js"></script>
    <script>
      let boxEle = document.getElementById('box')
      let btnEle = document.getElementById('btn')
      btnEle.addEventListener('click', function () {
        axios.get('http://127.0.0.1:6001/music').then((response) => {
          let arr = response.data
          arr.forEach(item => {
            boxEle.innerHTML += item.id + item.musicName
          })
        })
      })
    </script>
  </body>
</html>
